#include <rclcpp/rclcpp.hpp>
#include <tf2_ros/static_transform_broadcaster.h>
#include <geometry_msgs/msg/transform_stamped.hpp>
#include <tf2/LinearMath/Quaternion.h>

class StaticTFBroadcaster:public rclcpp::Node{
public:
    explicit StaticTFBroadcaster(std::string name):Node(name){
        static_tf_bc_=std::make_shared<tf2_ros::StaticTransformBroadcaster>(this);
    }

    void makeTransform(){
        // 2
        geometry_msgs::msg::TransformStamped tf_obj;
        // 3: fill
        tf_obj.header.stamp=this->get_clock()->now();
        tf_obj.header.frame_id="world";
        tf_obj.child_frame_id="house";

        // translation
        tf_obj.transform.translation.x=10.0;
        tf_obj.transform.translation.y=5.5;
        tf_obj.transform.translation.z=0.0;

        // rotation
        // quat obj
        tf2::Quaternion q;
        q.setRPY(0.0,0.0,0.0);
        tf_obj.transform.rotation.x=q[0];
        tf_obj.transform.rotation.y=q[1];
        tf_obj.transform.rotation.z=q[2];
        tf_obj.transform.rotation.w=q[3];

        // 4:publish
        static_tf_bc_->sendTransform(tf_obj);
    }

private:
    // 1
    std::shared_ptr<tf2_ros::StaticTransformBroadcaster> static_tf_bc_{nullptr};
};

int main(int argc,char** argv){
    rclcpp::init(argc,argv);
    auto node=std::make_shared<StaticTFBroadcaster>("static_tf_broadcaster");
    node->makeTransform();
    rclcpp::spin(node);
    rclcpp::shutdown();

    return 0;
}